let height = [1, 8, 6, 2, 5, 4, 8, 3, 7]
var maxArea = function (height) {
    let max = -Infinity
    let left = 0
    let right = height.length - 1
    while (left !== right) {
        let min = Math.min(height[left], height[right])
        // if (min * (right - left) > max) {
        //     max = min * (right - left)
        // }
        max = Math.max(max, ((right - left) * min))
        if (min === height[left]) {
            left++
        } else {
            right--
        }
    }
    return max
};
console.log(maxArea(height));
